package com.biz.primus.ms.sms.dao.po;

import com.biz.primus.model.misc.enums.ApiExceptionType;
import com.biz.primus.model.misc.enums.MessageType;
import com.biz.primus.model.misc.enums.SignaturePosition;
import com.biz.primus.ms.base.jpa.po.BaseEntity;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;

/**
 * @author yanweijin
 * @date 2017/5/30
 */
@Entity
@DiscriminatorColumn(name = "send_type", length = 16)
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorValue("single")
@Table(name = "cmp_send_task", indexes = @Index(columnList = "receiver"))
@Getter
@Setter
public class SendTask extends BaseEntity {


    private static final long serialVersionUID = 1286267734950566899L;
    @Column(length = 64, name = "channel_code")
    private String channelCode;

    @Column(length = 32, name = "channel_name")
    private String channelName;

    @Column(length = 32, name = "provider_id")
    private String providerId;

    @Column(length = 32, name = "provider_name")
    private String providerName;

    @Column(length = 64, name = "send_request_id")
    private String sendRequestId;

    @Column(length = 64, name = "batch_number")
    private String batchNumber;

    @Enumerated(EnumType.STRING)
    @Column(length = 32, name = "message_type")
    private MessageType messageType;

    //接收人数量
    @Column(name = "receiver_number")
    private Integer receiverNumber = 1;

    private String content;

    @Column(length = 16, nullable = false)
    private String receiver = "";

    /**
     * 折算成多少条短信,超过70字后每67字算一条
     * 计算方式为 (content+signature+2).length > 70 ?  ((content+signature+2).length / 67) +1 : 1
     */
    @Column(name = "convert_message_number")
    private Integer convertMessageNumber;

    @Column(length = 8)
    private String signature;

    @Column(columnDefinition = "TEXT")
    private String extra;

    @Column(length = 32, name = "send_result")
    @Enumerated(EnumType.STRING)
    private ApiExceptionType sendResult;

    @Enumerated(EnumType.STRING)
    @Column(name = "signature_position", length = 32)
    private SignaturePosition signaturePosition;

}
